Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Loading...
Searching...
No Matches
freq_estimator.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2015 Roc authors
3 *
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 */
8
9//! @file roc_audio/freq_estimator.h
10//! @brief Frequency estimator.
11
12#ifndef ROC_AUDIO_FREQ_ESTIMATOR_H_
13#define ROC_AUDIO_FREQ_ESTIMATOR_H_
14
16#include "roc_audio/units.h"
18#include "roc_packet/units.h"
19
20namespace roc {
21namespace audio {
22
23//! Evaluates sender's frequency to receivers's frequency ratio.
25public:
26 //! Initialize.
27 //!
28 //! @b Parameters
29 //! - @p target_latency defines latency we want to archive.
30 explicit FreqEstimator(packet::timestamp_t target_latency);
31
32 //! Get current frequecy coefficient.
33 float freq_coeff() const;
34
35 //! Compute new value of frequency coefficient.
36 void update(packet::timestamp_t current_latency);
37
38private:
39 bool run_decimators_(packet::timestamp_t current, float& filtered);
40 float run_controller_(float current);
41
42 const float target_; // Target latency.
43
44 float dec1_casc_buff_[fe_decim_len];
45 size_t dec1_ind_;
46
47 float dec2_casc_buff_[fe_decim_len];
48 size_t dec2_ind_;
49
50 size_t samples_counter_; // Input samples counter.
51 float accum_; // Integrator value.
52
53 float coeff_; // Current frequency coefficient value.
54};
55
56} // namespace audio
57} // namespace roc
58
59#endif // ROC_AUDIO_FREQ_ESTIMATOR_H_
Evaluates sender's frequency to receivers's frequency ratio.
void update(packet::timestamp_t current_latency)
Compute new value of frequency coefficient.
float freq_coeff() const
Get current frequecy coefficient.
FreqEstimator(packet::timestamp_t target_latency)
Initialize.
Base class for non-copyable objects.
Definition: noncopyable.h:23
Frequency estimator config.
uint32_t timestamp_t
Audio packet timestamp.
Definition: units.h:46
Root namespace.
Non-copyable object.
Various units used in audio processing.
Various units used in packets.